<template>
  <div class="gl_heightFull">
    <el-tabs v-model="activeTab" class="gl_tabs" type="card">
      <el-tab-pane v-for="(item, index) in tabList" :key="index" :label="item.label" :name="item.name">
        <component :is="item.component" v-if="activeTab === item.name" :store-id="storeId" />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import allGoods from './goodsList.vue';
import onShelf from './goodsListOnShelf.vue';
import inStorage from './goodsListInStorage.vue';
// import {
//   Api_GET_MallProductGroupQO
// } from '@/lib/form/shoppingmall/swaggerForm';
import {
  api_GET_MallStoreCurrent
} from '@/extend/api/shoppingmallswaggerApi/app.js';

export default {
  data () {
    return {
      activeTab: 'allGoods',
      storeId: '',
      tabList: [
        {
          label: '全部商品',
          name: 'allGoods',
          productStatus: '',
          component: allGoods
        },
        {
          label: '销售中',
          name: 'onShelf',
          productStatus: 'OnShelf',
          component: onShelf
        },
        {
          label: '仓库中',
          name: 'inStorage',
          productStatus: 'InStorage',
          component: inStorage
        }
      ]
    };
  },
  created() {
    this.activeTab = this.$route.query.activeTab || 'allGoods';
    this.api_GET_MallStoreCurrent();
  },
  methods: {
    // 获取当前用户店铺信息
    api_GET_MallStoreCurrent() {
      api_GET_MallStoreCurrent({ IncludeStatus: true }).then(res => {
        this.storeId = res.id || '';
      }, error => {
        const _msg = error.error.message || error.message;
        this.$message({ type: 'error', message: _msg });
      });
    }
  }
};
</script>

<style lang="scss" scoped>

</style>
